package cn.edu.scau.cmi.luotiansheng.adapter;

import java.util.ArrayList;
import java.util.List;


public class ObjectAdapter implements StudentInterface {
	
	private List<Student> studentList=new ArrayList<Student>();
	private SortUtil sortUtil=new SortUtil();
	
	
	public List<Student> getStudentList() {
		return studentList;
	}

	public void setStudentList(List<Student> studentList) {
		this.studentList = studentList;
	}

	@Override
	public List sortInt(List<Integer> list) {
		// TODO Auto-generated method stub
		return sortUtil.sortInt(list);
	}

	@Override
	public List sortStudent() {
		// TODO Auto-generated method stub
		List<Integer> listSno=new ArrayList<Integer>();
		for(int i=0;i<studentList.size();i++) {
			listSno.add(studentList.get(i).getSno());
		}
		sortInt(listSno);
		List<Student> tempList=new ArrayList<Student>();
		for(int i=0;i<studentList.size();i++) {
			for(int j=0;j<studentList.size();j++) {
				if(listSno.get(i)==studentList.get(j).getSno()) {
					tempList.add(studentList.get(j));
					break;
				}
			}
		}
		studentList=tempList;
		
		for(int i=0;i<studentList.size();i++) {
			System.out.println(studentList.get(i).getName()+"\n");
		}
		
		return studentList;
	}

}
